{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 59,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn import datasets\n",
    "from sklearn.neighbors import KNeighborsClassifier\n",
    "import numpy as np\n",
    "from sklearn.model_selection import train_test_split\n",
    "from matplotlib import pyplot as plt\n",
    "from sklearn.model_selection import GridSearchCV"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "X=np.random.randint(0,100,(50,2))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "X=np.array(X,dtype=float)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[81., 70.],\n",
       "       [94., 99.],\n",
       "       [52., 98.],\n",
       "       [81.,  3.],\n",
       "       [64., 12.],\n",
       "       [45., 42.],\n",
       "       [24., 63.],\n",
       "       [24., 66.],\n",
       "       [79., 11.],\n",
       "       [80., 36.]])"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "X[:10]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [],
   "source": [
    "X[:,0] = (X[:,0]-np.min(X[:,0]))/(np.max(X[:,0]-np.min(X[:,0])))\n",
    "X[:,1] = (X[:,1]-np.min(X[:,1]))/(np.max(X[:,1]-np.min(X[:,1])))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[0.81443299, 0.70707071],\n",
       "       [0.94845361, 1.        ],\n",
       "       [0.51546392, 0.98989899],\n",
       "       [0.81443299, 0.03030303],\n",
       "       [0.63917526, 0.12121212],\n",
       "       [0.44329897, 0.42424242],\n",
       "       [0.22680412, 0.63636364],\n",
       "       [0.22680412, 0.66666667],\n",
       "       [0.79381443, 0.11111111],\n",
       "       [0.80412371, 0.36363636]])"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "X[:10]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1.0"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "X=np.random.randint(0,100,(50,2))\n",
    "X=np.array(X,dtype=float)\n",
    "for i in range(0,2):\n",
    "    X[:,i] = (X[:,i]-np.mean(X[:,i]))/(np.std(X[:,i]))\n",
    "np.std(X[:,0])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/anaconda3/lib/python3.6/site-packages/numpy/core/fromnumeric.py:2957: RuntimeWarning: Mean of empty slice.\n",
      "  out=out, **kwargs)\n",
      "/anaconda3/lib/python3.6/site-packages/numpy/core/_methods.py:80: RuntimeWarning: invalid value encountered in double_scalars\n",
      "  ret = ret.dtype.type(ret / rcount)\n"
     ]
    },
    {
     "ename": "ValueError",
     "evalue": "could not broadcast input array from shape (0,2) into shape (50)",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mValueError\u001b[0m                                Traceback (most recent call last)",
      "\u001b[0;32m<ipython-input-18-86311b57dba3>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m      1\u001b[0m \u001b[0mX\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mrandom\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mrandint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m100\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m50\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0mX\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0mX\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m-\u001b[0m\u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmean\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mX\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m/\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mstd\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mX\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[0;31mValueError\u001b[0m: could not broadcast input array from shape (0,2) into shape (50)"
     ]
    }
   ],
   "source": [
    "X=np.random.randint(0,100,(50,2))\n",
    "X[:,0] = (X[:0]-np.mean(X[:0]))/(np.std(X[:,0]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([38, 39, 27,  8, 18, 65,  7, 88, 54, 21, 27, 37, 65, 33,  0, 78,  1,\n",
       "       10, 26, 89, 19, 34, 50, 67, 57, 83, 23, 16, 21,  9, 63, 85, 66, 91,\n",
       "       68,  7, 82, 16, 84, 57,  7, 38, 48, 91, 61, 42, 43, 46, 85, 46])"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "X[:,0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/anaconda3/lib/python3.6/site-packages/numpy/core/fromnumeric.py:2957: RuntimeWarning: Mean of empty slice.\n",
      "  out=out, **kwargs)\n",
      "/anaconda3/lib/python3.6/site-packages/numpy/core/_methods.py:80: RuntimeWarning: invalid value encountered in double_scalars\n",
      "  ret = ret.dtype.type(ret / rcount)\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "array([], shape=(0, 2), dtype=float64)"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "X[:0]-np.mean(X[:0])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 79,
   "metadata": {},
   "outputs": [],
   "source": [
    "from KNN import Standard\n",
    "X = np.random.randint(0,100,size=(50,4))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 80,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[49,  3, 39, 92],\n",
       "       [11, 81, 84, 56],\n",
       "       [36, 69, 66, 20],\n",
       "       [18, 68, 85, 90],\n",
       "       [21, 49, 86, 10],\n",
       "       [36, 28, 95, 49],\n",
       "       [98, 16, 13, 50],\n",
       "       [60, 34,  3, 95],\n",
       "       [88,  2, 52, 88],\n",
       "       [54, 13, 13, 21],\n",
       "       [ 1, 23, 52, 49],\n",
       "       [84, 54,  6, 50],\n",
       "       [45, 26, 49, 42],\n",
       "       [69, 78, 12, 23],\n",
       "       [ 7, 36, 63, 50],\n",
       "       [46, 82, 58, 99],\n",
       "       [27, 44, 29, 98],\n",
       "       [56,  2, 23, 10],\n",
       "       [45, 21, 29, 63],\n",
       "       [21, 31, 74, 83],\n",
       "       [25, 63, 75, 32],\n",
       "       [95, 86, 37, 88],\n",
       "       [66, 63, 16, 55],\n",
       "       [91, 18, 97, 82],\n",
       "       [56, 98, 50, 24],\n",
       "       [78, 29, 73, 62],\n",
       "       [29, 31, 80, 85],\n",
       "       [80, 96, 37, 84],\n",
       "       [64, 17, 86, 78],\n",
       "       [ 1, 68, 82, 51],\n",
       "       [82, 90, 89, 93],\n",
       "       [14, 91, 86, 11],\n",
       "       [39, 56, 35, 38],\n",
       "       [ 8, 73, 49, 73],\n",
       "       [81,  4,  2, 51],\n",
       "       [17, 84, 47, 33],\n",
       "       [51,  5, 65,  2],\n",
       "       [82, 97, 90, 66],\n",
       "       [13, 63,  0, 99],\n",
       "       [73, 54, 56, 78],\n",
       "       [56, 16, 27, 73],\n",
       "       [73, 39, 18, 28],\n",
       "       [ 5, 55, 14, 63],\n",
       "       [ 1, 39, 64, 21],\n",
       "       [49, 11, 89, 62],\n",
       "       [ 9, 84, 75,  0],\n",
       "       [84, 96, 11, 69],\n",
       "       [22, 85, 59, 18],\n",
       "       [11, 26, 72, 36],\n",
       "       [10, 47, 82,  5]])"
      ]
     },
     "execution_count": 80,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "X"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 81,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<module 'numpy' from '/anaconda3/lib/python3.6/site-packages/numpy/__init__.py'>"
      ]
     },
     "execution_count": 81,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Standard.np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "Standard."
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
